Skip to content

rolldown: turn off constant inlining by default - #214

Merged
NullVoxPopuli merged 2 commits into
NullVoxPopuli:mainfrom
NullVoxPopuli-ai-agent:nvp/inline-const-vs-template-scope
Nov 21, 2026
Merged

NullVoxPopuli merged 2 commits into
NullVoxPopuli:mainfrom
NullVoxPopuli-ai-agent:nvp/inline-const-vs-template-scope

Conversation

@NullVoxPopuli-ai-agent

@NullVoxPopuli-ai-agent NullVoxPopuli-ai-agent commented Nov 21, 2026 •

Copy link
Copy Markdown
Contributor

Replaces #114, rebased onto the newest main. The agent account cannot push to the #114 branch, so this PR comes from the agent fork.

emberConfig() now sets rolldown's optimization.inlineConst to false by default. rolldown's default (mode: "smart") puts an imported constant's literal into precompileTemplate scope objects:

scope: () => ({ EMPTY_VALUE_PLACEHOLDER })
// bundles to
scope: () => ({ EMPTY_VALUE_PLACEHOLDER: "—" })

The consuming app's template compiler rejects that output with "Scope objects for precompileTemplate may only contain direct references to in-scope values ... Found StringLiteral". The library builds, type-checks, and lints clean, so the first error shows when the app boots.

On 2026-11-21 this still happened with rolldown 1.3.3, the newest version for ^1.2.0. The upstream compiler issue, emberjs/babel-plugin-ember-template-compilation#116, is still open. Its fix, emberjs/babel-plugin-ember-template-compilation#125, makes the compiler accept literal scope values and waits for review. Apps on 4.0.1 or older still reject inlined constants, so this default stays useful after #125 releases.

The default goes through rolldown's options hook, so it holds under tsdown and plain rolldown. An explicit optimization value still wins.

src/config.test.ts runs real rolldown builds. It covers the rolldown default that inlines the constant, the emberConfig() default that keeps the reference, and explicit options that still win.

These tests did not run locally. CI runs them.

🤖 Generated with Claude Code

rolldown's default `optimization.inlineConst` (`mode: "smart"`) puts an
imported constant's literal into `precompileTemplate` scope objects.
`scope: () => ({ EMPTY })` becomes `scope: () => ({ EMPTY: "—" })`.
The consuming app's template compiler accepts only direct references
there, so the published library fails when the app compiles it.

`emberConfig()` now sets `optimization.inlineConst` to `false` through
rolldown's `options` hook, so the default holds under tsdown and plain
rolldown. An explicit `optimization` value still wins.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@NullVoxPopuli NullVoxPopuli added the bug Something isn't working label Nov 21, 2026
@NullVoxPopuli
NullVoxPopuli merged commit 9f43207 into NullVoxPopuli:main Nov 21, 2026
13 of 14 checks passed
This was referenced Nov 21, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants